<template>
    <div class="demo3">
        <h2>姓名:{{name}}</h2>
        <h2>年龄:{{age}}</h2>
        <button @click="sendStudentName">把学生名给School组件</button>
    </div>
</template>

<script>
    export default {
        name:'Student',
        data() {
            return {
                name:'潘定道',
                age:22
            }
        },
        mounted() {//生命周期钩子函数
            //console.log("Student:"+this.x);
        },
        methods:{
            sendStudentName(){
                this.$bus.$emit('hello',this.name)//暴露自定义事件
            }
        }
    }
</script>

<style scoped>
    .demo3{
        background-color: skyblue;
    }
</style>